home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 5.1 KB | 156 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMemHlp.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWMEMHLP_H
- #define FWMEMHLP_H
-
- #ifndef FWCOMMON_H
- #include "FWCommon.h"
- #endif
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // CLASS FW_CAcquireLockedSystemHandle
- //
- // A resource acquisition helper object for locking a system handle within a scope.
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CAcquireLockedSystemHandle FW_AUTO_DESTRUCT_OBJECT
- {
- public:
- FW_CAcquireLockedSystemHandle(FW_PlatformHandle aSystemHandle);
- virtual ~ FW_CAcquireLockedSystemHandle();
-
- void* GetPointer() const;
-
- private:
- FW_CAcquireLockedSystemHandle(const FW_CAcquireLockedSystemHandle& acquireObject);
- FW_CAcquireLockedSystemHandle& operator=(const FW_CAcquireLockedSystemHandle& acquireObject);
- // Copy constructor and assignment operator not valid for this class.
-
- FW_PlatformHandle fLockedSystemHandle;
- void* fLockedPointer;
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireLockedSystemHandle::GetPointer
- //----------------------------------------------------------------------------------------
-
- inline void* FW_CAcquireLockedSystemHandle::GetPointer() const
- {
- return fLockedPointer;
- }
-
- //========================================================================================
- // CLASS FW_CAcquireTemporarySystemHandle
- //
- // A resource acquisition helper object for allocating and locking a system handle
- // within a scope. You can transfer ownership of the handle by calling OrphanPointer.
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CAcquireTemporarySystemHandle FW_AUTO_DESTRUCT_OBJECT
- {
- public:
- FW_CAcquireTemporarySystemHandle(unsigned long size);
- virtual ~ FW_CAcquireTemporarySystemHandle();
-
- void Resize(unsigned long newSize);
-
- void* Orphan();
- FW_Boolean IsOrphan() const;
-
- FW_PlatformHandle GetPlatformHandle() const;
- void* GetPointer() const;
-
- private:
- FW_PlatformHandle fTemporarySystemHandle;
- void* fMemoryPointer;
- FW_Boolean fFree; // If TRUE, the dtor will free the fMemory
-
- private:
- FW_CAcquireTemporarySystemHandle(const FW_CAcquireTemporarySystemHandle& acquireObject);
- FW_CAcquireTemporarySystemHandle& operator=(const FW_CAcquireTemporarySystemHandle& acquireObject);
- // Copy constructor and assignment operator not valid for this class.
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireTemporarySystemHandle::GetPointer
- //----------------------------------------------------------------------------------------
-
- inline void* FW_CAcquireTemporarySystemHandle::GetPointer() const
- {
- return fMemoryPointer;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireTemporarySystemHandle::GetPlatformHandle
- //----------------------------------------------------------------------------------------
-
- inline FW_PlatformHandle FW_CAcquireTemporarySystemHandle::GetPlatformHandle() const
- {
- return fTemporarySystemHandle;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireTemporarySystemHandle::Orphan
- //----------------------------------------------------------------------------------------
-
- inline void* FW_CAcquireTemporarySystemHandle::Orphan()
- {
- FW_ASSERT(fFree == TRUE);
- fFree = FALSE;
- return fMemoryPointer;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireTemporarySystemHandle::IsOrphan
- //----------------------------------------------------------------------------------------
-
- inline FW_Boolean FW_CAcquireTemporarySystemHandle::IsOrphan() const
- {
- return !fFree;
- }
-
- #ifdef FW_BUILD_MAC
- //========================================================================================
- // CLASS FW_CMacAcquireMultiFinderHeapZone
- //
- // A resource acquisition helper object to set the current heap zone to be the multifinder
- // heap zone. This is very useful for example with QuickTime.
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CMacAcquireMultiFinderHeapZone FW_AUTO_DESTRUCT_OBJECT
- {
- public:
- FW_CMacAcquireMultiFinderHeapZone();
- virtual ~ FW_CMacAcquireMultiFinderHeapZone();
-
- private:
- THz fOldHeap;
-
- private:
- FW_CMacAcquireMultiFinderHeapZone(const FW_CMacAcquireMultiFinderHeapZone& acquireObject);
- FW_CMacAcquireMultiFinderHeapZone& operator=(const FW_CMacAcquireMultiFinderHeapZone& acquireObject);
- // Copy constructor and assignment operator not valid for this class.
- };
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-